package com.spring.common.taglib.tool;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;

import org.apache.log4j.Logger;

import com.spring.common.constant.Constant;
import com.spring.common.util.DESCrypter;
/**
 * @author lilongshun
 * @version 1.0.0
 * @date Apr 18, 2011 9:31:54 AM
 * 解密，加密
 */
public class DesTool extends TagSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3755092289261175810L;
	private Logger log = Logger.getLogger(DesTool.class);
	/**
	 * input id
	 */
	private String value;
	public String getValue() {
		return value;
	}
	public void setValue(String value) {
		this.value = value;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see javax.servlet.jsp.tagext.TagSupport#doEndTag()
	 */
	@Override
	public int doEndTag() throws JspException {
		//获取数据源
		String v=DESCrypter.encrypt(value, Constant.DES_KEY);
		try {
			pageContext.getOut().print(v);
		} catch (Exception e) {
			log.error("DesTool加密工具出现异常" + e.getMessage(), e);
		}
		return EVAL_PAGE;
	}	
}
